/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util.components;

import java.awt.Color;
import java.awt.Font;
import javax.swing.JPanel;
import javax.swing.UIManager;

/**
 *
 * @author raul
 */
public class RoundedTitlePanel extends JPanel {
    
    private String title;

    public RoundedTitlePanel() {
        this.setTitle("Titulo");
        setearFuente();
    }
    
    private void setearFuente(){
        Font labelFont = UIManager.getFont("Label.font");
        setFont(labelFont.deriveFont(Font.BOLD, labelFont.getSize()+2f));
//        Color bg = Utilities.deriveColorHSB(UIManager.getColor("Panel.background"), 0, 0, -.06f);
//        setBackground(bg);
        setForeground(Color.getHSBColor(coloresHsb()[0], .54f, .40f));
    }
    
//    private boolean usingNimbus() {
//        return UIManager.getLookAndFeel().getName().equals("Nimbus");
//    }
    
    public void setTitle(String title){
        float hsb[] = coloresHsb();
        setBorder(new RoundedTitleBorder(title,
                Color.getHSBColor(hsb[0]-.013f, .15f, .85f),
                Color.getHSBColor(hsb[0]-.005f, .24f, .80f))
        );
        this.title = title;
    }
    
    public String getTitle(){
        return title;
    }
    
    private float[] coloresHsb(){
        Color titleColor = new Color(127, 157, 185, 1);
//                UIManager.getColor(usingNimbus()? "nimbusBase" : "activeCaption");
//        //some LAFs don't contain active caption
//        if (titleColor == null) {
//            titleColor = Color.LIGHT_GRAY;
//        }
        return Color.RGBtoHSB(
                titleColor.getRed(), titleColor.getGreen(), titleColor.getBlue(), null);
    }
}
